package com.androidhelper.module.common.utils;

import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

import com.androidhelper.module.common.app.LibApplication;


/**
 * name：
 * describe:
 * author: LSJ
 * time 19/3/18 上午11:58
 */
public class ToastUtils {
    public static void showInMiddle( String message) {

        Toast toast = Toast.makeText(LibApplication.getInstance().getApplicationContext(), message, Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
    }

    public static void showInMiddle( int resId) {
        Toast toast = Toast.makeText(LibApplication.getInstance().getApplicationContext(), resId, Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
    }

    public static void showSingleToastInMiddle( int resId, int imageType) {
        showSingleToastInMiddle(LibApplication.getInstance().getApplicationContext(), LibApplication.getInstance().getApplicationContext().getResources().getText(resId).toString(), imageType);
    }

    public static void showSingleToastInMiddle(Context appContext, String content, int imageType) {
        CenterToast.showToast(LibApplication.getInstance().getApplicationContext(), content, Toast.LENGTH_SHORT, imageType);
    }

    public static void showSingleToastInTop(Context appContext, String content, int imageType) {
        TopToast.showToast(LibApplication.getInstance().getApplicationContext(), content, Toast.LENGTH_LONG, imageType);
    }

    public static void showSingleToastLongInMiddle(Context context, String content, int imageType) {
        CenterToast.showToast(context, content, Toast.LENGTH_LONG, imageType);
    }

    public static void showTextInMiddle( String content) {
        showSingleToastInMiddle(LibApplication.getInstance().getApplicationContext(), content, CenterToast.TYPE_HIDE);
    }

    public static void showTextInTop( String content) {
        showSingleToastInTop(LibApplication.getInstance().getApplicationContext(), content, CenterToast.TYPE_HIDE);
    }

    public static void showTextInMiddle( int resId) {
        showSingleToastInMiddle(LibApplication.getInstance().getApplicationContext(), LibApplication.getInstance().getApplicationContext().getResources().getText(resId).toString(), CenterToast.TYPE_HIDE);
    }


    public static void showErrorImage( String content) {
        showSingleToastInMiddle(LibApplication.getInstance().getApplicationContext(), content, CenterToast.TYPE_ERROR);
    }

    public static void showLongErrorImage( String content) {
        showSingleToastLongInMiddle(LibApplication.getInstance().getApplicationContext(), content, CenterToast.TYPE_ERROR);
    }

    public static void showErrorImage(int resId) {
        showSingleToastInMiddle(LibApplication.getInstance().getApplicationContext(), LibApplication.getInstance().getApplicationContext().getResources().getText(resId).toString(), CenterToast.TYPE_ERROR);
    }

    public static void showCorrectImage(String content) {
        showSingleToastInMiddle(LibApplication.getInstance().getApplicationContext(), content, CenterToast.TYPE_CORRECT);
    }

    public static void showCorrectImage( int resId) {
        showSingleToastInMiddle(LibApplication.getInstance().getApplicationContext(), LibApplication.getInstance().getApplicationContext().getResources().getText(resId).toString(), CenterToast.TYPE_CORRECT);
    }
}
